package com.healthy.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author ????
 * @date 2020年6月10日
 * @description <p>获得时间的工具类</p>
 */
public class Dateutil {
	public final static String sqlDateFormat = "%y-%m-%d";
    public final static String sqlDateTimeFormat = "%y-%m-%d %T";
    public final static String DateFormat = "yyyy-MM-dd";
    public final static String myDateutil = "yyyy-MM-dd HH:mm:ss";
    public final static String SimpleDateTimeFormat = "yyyy-MM-dd HH:mm";
    public final static String TimeStamp="yyyyMMddHHmmssSSS";
    
    /*
     * 获得Date
     */
    public static Date getCurrentDateTime() throws ParseException {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat(myDateutil);
        return sdf.parse(sdf.format(date));
    }
    
    /*
     * 获得DateString
     */
    public static String getCurrentDateText() {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat(myDateutil);
        return sdf.format(date);
    }
    
    /*
     * 获取至毫秒级DateString,即时间戳
     */
    public static String getTimeStampString(){
    	Date date = new Date();
    	SimpleDateFormat simpleDateFormat=new SimpleDateFormat(TimeStamp);
    	return simpleDateFormat.format(date);
    }
    
    /*
     * 通过函数转化Date为指定格式的时间字符串
     */
    public static String getFormatTimeString(String format, Date date) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(date);
	}
}
